package com.example.elan.Controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.text.DateFormat;
import java.util.Date;
import java.util.Locale;

/**
 * @ClassName ThymeleafController
 * @Description TODO
 * @Author Adiljan
 * @Date 2019/11/5 18:42
 **/
@Controller
@RequestMapping("/adl")
public class ThymeleafController {

    @RequestMapping("/hello")
    public String hello(Locale locale, Model model) {
        model.addAttribute("greeting", "Hello!");

        Date date = new Date();
        DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, locale);
        String formattedDate = dateFormat.format(date);
        model.addAttribute("currentTime", formattedDate);

        return "layout";
    }

    @RequestMapping("/layout")
    public String layout(Locale locale, Model model) {
        model.addAttribute("greeting", "Helloooo!");

        return "layout";
    }

    @RequestMapping("/test")
    public String test(Locale locale, Model model) {
        return "views/index";
    }


}
